package com.adms.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.adms.domain.CircularReply;
import com.adms.service.CircularReplyService;

@RequestMapping("circular/reply")
@RestController
public class CircularReplyController {

	@Autowired
	public CircularReplyService circularReplyService;
	
	@GetMapping("{replyId}")
	public Object getByReplyId(@PathVariable("replyId") Integer replyId) {
		return circularReplyService.getByReplyId(replyId);
	}
	
	@GetMapping
	public Object list(CircularReply circularReply,Boolean isSelf,String timeField,Date start,Date end,String orderByClause,
			@RequestParam(defaultValue = "1") Integer pageNum,
			@RequestParam(defaultValue = "5") Integer pageSize,
			@RequestParam(defaultValue = "5") Integer navigatePages) {
		return circularReplyService.list(circularReply,isSelf,timeField,start,end,orderByClause,pageNum,pageSize,navigatePages);
	}
	
	@PostMapping("audit")
	public Object audit(@RequestParam("replyId") Integer replyId,
			@RequestParam("auditState") Integer auditState) {
		return circularReplyService.audit(replyId,auditState);
	}
}
